//  me-store.js
const util = require('../../utils/util.js')
const app = getApp()

Page({
  data: {
   //可提现金额
   withdrawable_cash:5500.88,
   //提现方式数组
   withdrawWays:{
     type:0,
     list:[
       {name:'微信',img:'images/wechat.png'},
        {name:'支付宝',img:'images/alipay.png'}
     ]
   },
   //金额输入值
   withdraw_cash:''
  },
  //监听金额输入
  inputCash(e){
    var value = e.detail.value,that = this.data;
    if(value > that.withdrawable_cash){
      util.tip('超出可提现金额！')
      this.setData({
        withdraw_cash:that.withdrawable_cash
      })
    }
  },
  //选择提现方式
  select(e){
    var selectedIndex = e.currentTarget.dataset.index;
    var selected = 'withdrawWays.type';
    this.setData({
      [selected]:selectedIndex
    })
  },
  //发起提现
  launch(e){
    var values = e.detail.value,that = this.data;
    //判断是否输入提现金额
    if(!values.withdraw_cash){
      util.tip('请输入提现金额')
      return;
    }
    //判断是否输入微信账号
    if(!values.account){
      if(that.withdrawWays.type == 0) util.tip('请输入微信账号')
      else util.tip('请输入支付宝账号')
      return;
    }
  },
  onLoad() {
   
  },
  
})
